﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;
using SqlSugar.Extensions;
using System;
using System.ComponentModel;

namespace NCP.Model
{
    [SugarTable("v_ALLDeptDrugCompare")]
    public class VALLDeptDrugCompare
    {

       
       
            public string GpCode { get; set; }

            [Description("集采名称")]
            public string GpName { get; set; }

            public string DrugCode { get; set; }
            [Description("中选药品名称")]
            public string DrugName { get; set; }
            [Description("中选药品规格")]
            public string Specs { get; set; }
            [Description("中选药品单价")]
            public string UnitPrice { get; set; }

            //[Description("中选药品包装数量")]
            //public string PackQty { get; set; }

            [Description("生产厂家")]
            public string ProducerName { get; set; }
            [Description("中选药品最小计价单位的含量换算系数")]
            public string Ratio { get; set; }

            [Description("中选药品医保局规定使用占比")]
            public decimal TaskRatio { get; set; }

            [SugarColumn(IsIgnore = true)]
            public string TaskRatioStr
            {
                get
                {
                    return Math.Round(TaskRatio * 100, 2).ToString() + "%";
                }
            }

            [Description("开始时间")]
            public DateTime? BeginDate { get; set; }
            [Description("结束时间")]
            public DateTime? EndDate { get; set; }
            [Description("中选药品年度任务量")]
            public int TaskQty { get; set; }
            [Description("科室代码")]
            public string DeptCode { get; set; }
            [Description("科室名称")]
            public string DeptName { get; set; }
            //[Description("科室年度任务量")]
            //public int DeptQty { get; set; }
            //[Description("科室完成比例")]
            //public int DeptRate { get; set; }

            public string UDrugCode { get; set; }
            [Description("中选药品名称")]
            public string UDrugName { get; set; }
            [Description("中选药品规格")]
            public string USpecs { get; set; }

            [Description("生产厂家")]
            public string UProducerName { get; set; }

            //[Description("科室")]
            //public string SubDeptCode { get; set; }

            //[SugarColumn(IsIgnore = true)]
            //[Explain(CacheKey = KeyEnum.Dept, SourceField = "SubDeptCode")]
            //public string SubDeptName { get; set; }

            #region 

            //[SugarColumn(IsIgnore =true)]
            //[Description("中选药品入库数量")]
            //public decimal InNum { get; set; }

            [Description("中选药品使用数量")]
            public decimal UseNum { get; set; }

            [Description("非中选药品使用数量")]
            public decimal FUseNum { get; set; }

            [SugarColumn(IsIgnore = true)]
            [Description("中选药品任务完成进度")]
            public string TaskRate
            {
                get
                {
                    return Math.Round(TaskQty == 0 ? 100 : UseNum * 100 / TaskQty, 2).ToString() + "%";
                }
            }

            [Description("中选药品使用占比")]
            public decimal UseRatio
            {
                get; set;
            }

            [SugarColumn(IsIgnore = true)]
            public string UseRatioStr
            {
                get
                {
                    return Math.Round(UseRatio * 100, 2).ToString() + "%";
                }
            }
            [Description("结束时间")]
            [SugarColumn(IsIgnore = true)]
            public string EndDateStr
            {
                get
                {
                    if (EndDate.HasValue)
                        return EndDate.Value.ToString("yyyy-MM-dd");
                    return "";
                }
            }

            [Description("非中选药品可使用比率")]
            [SugarColumn(IsIgnore = true)]
            public string FTaskRatio
            {
                get
                {
                    return (Math.Round(100 - TaskRatio.ObjToDecimal(), 2)).ToString() + "%";
                }
            }
        [Description("最小单位")]
        public string MinUnit
        {
            get; set;
        }
        #endregion
    }
    
}
